package com.system.orderserver.bus;


import com.alibaba.fastjson.JSONObject;
import com.system.orderserver.result.OrdersInfo_Result;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OrderSender {


    @Autowired
    private AmqpTemplate amqpTemplate;

    public void sendOrderMsg(Integer orderId, OrdersInfo_Result ordersInfo_result){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("orderId",orderId);
        jsonObject.put("orderInfo",ordersInfo_result);
        this.amqpTemplate.convertAndSend("exchang2","",jsonObject.toJSONString());
    }

    public void sendIntegral(Integer orderId) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("orderId",orderId);
        this.amqpTemplate.convertAndSend("orderserverIntegral",jsonObject.toString());
    }
}
